package com.minelx.scriptbuilder.parse.matcher;

import com.minelx.sequence.IStringScanner;
import com.minelx.sequence.ReturnMatcher;
import com.minelx.scriptbuilder.script.IVariable;
import com.minelx.scriptbuilder.script.attribute.value.StringValue;

public class StringMatcher implements ReturnMatcher<IVariable, IStringScanner> {
	@Override
	public boolean isMatch(IStringScanner scanner) {
		return scanner.exists("\"");
	}

	@Override
	public IVariable onMatched(IStringScanner scanner) {
		scanner.nextChar();
		String content = scanner.til('"');
		scanner.nextChar();
		return IVariable.immediate(new StringValue(content));
	}
}
